cast text as date

Поиск
Список
Период
Сортировка
От lynch@lscorp.com (Richard Lynch)
Тема cast text as date
Дата
Msg-id v02140b24b1ab8fc52a9f@[207.152.64.133]
обсуждение исходный текст
Ответы Re: [SQL] cast text as date
Список pgsql-sql
I'm probably an idiot, but I can't find a way in the docs or archives to
cast from text to date.  The text field in question looks like a date, and
I know there's a function to parse it 'cuz if it were in a table to be
imported using \copy it would work, but what that function would be called,
I'm failing to guess...  Does that make sense?

Here's the mess I've created:

I've got two tables that I need to "merge".  Both have mostly the same
fields but t1 has type 'text' on fields that are really, really dates, and
t1 has more rows than t2.  So I'm using:

insert into t2 select blah, blah, cast (blah as date) from t1 where not
exists (select id from t2 where t2.id = t1.id);

Maybe I'm just going about this all wrong...

I've never created a function of my own, and maybe that's the way to go,
but I'm not sure where to start...
The strings in question actually only have a month/year (no date), if that
matters (they're expirations)...
The resulting date can just default to 1 for the date.

--
--
-- "TANSTAAFL" Rich lynch@lscorp.com



В списке pgsql-sql по дате отправления:

Предыдущее
От: David Hartwig
Дата:
Сообщение: Re: [SQL] Binary large objects
Следующее
От: "Francois TETE"
Дата:
Сообщение: Rule "Delete"